package com.ruoyi.myplayer.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.myplayer.domain.PlayerYuedan;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IPlayerYuedanService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 乐单Controller
 * 
 * @author ruoyi
 * @date 2025-02-24
 */
@RestController
@RequestMapping("/myplayer/yuedan")
public class PlayerYuedanController extends BaseController
{
    @Resource
    private IPlayerYuedanService playerYuedanService;

    /**
     * 查询乐单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PlayerYuedan playerYuedan)
    {
        startPage();
        List<PlayerYuedan> list = playerYuedanService.selectPlayerYuedanList(playerYuedan);
        return getDataTable(list);
    }


    /**
     * 获取乐单详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(playerYuedanService.selectPlayerYuedanById(id));
    }

    /**
     * 新增乐单
     */
    @PreAuthorize("@ss.hasPermi('system:yuedan:add')")
    @Log(title = "乐单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlayerYuedan playerYuedan)
    {
        return toAjax(playerYuedanService.insertPlayerYuedan(playerYuedan));
    }

    /**
     * 修改乐单
     */
    @PreAuthorize("@ss.hasPermi('system:yuedan:edit')")
    @Log(title = "乐单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlayerYuedan playerYuedan)
    {
        return toAjax(playerYuedanService.updatePlayerYuedan(playerYuedan));
    }

    /**
     * 删除乐单
     */
    @PreAuthorize("@ss.hasPermi('system:yuedan:remove')")
    @Log(title = "乐单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(playerYuedanService.deletePlayerYuedanByIds(ids));
    }
}
